package com.ph.irp.base.assistantmaterial.service.impl;

import java.util.List;

import com.ph.irp.base.assistantmaterial.dao.PBaseAssistantmaterialProductpurposeDAO;
import com.ph.irp.base.assistantmaterial.service.PBaseAssistantmaterialProductPurposeService;
import com.ph.irp.model.PBaseAssistantmaterialProductpurpose;

public class PBaseAssistantmaterialProductPurposeServiceImpl implements
		PBaseAssistantmaterialProductPurposeService {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5292366222743466609L;
	//辅助资料领料用途dao
	private PBaseAssistantmaterialProductpurposeDAO productPurposeDAOProxy = null;
	/**
	 * 新增辅助资料领料用途
	 */
	@Override
	public void addProductpurpose(
			PBaseAssistantmaterialProductpurpose productpurpose) throws Throwable{
		// TODO Auto-generated method stub
		productPurposeDAOProxy.addProductpurpose(productpurpose) ;
	}
	/**
	 * 根据id删除辅助资料领料用途
	 */
	@Override
	public void deleteProductpurpose(String[] productpurposeIds)throws Throwable {
		
		for(String productpurposeId : productpurposeIds)
			productPurposeDAOProxy.deleteProductpurpose(productpurposeId) ;
	
	}
	
	
	
	@Override
	public List<PBaseAssistantmaterialProductpurpose> getAllProductpurposes()
			throws Throwable {
		return productPurposeDAOProxy.getAllproductpurposes();
	}
	@Override
	public List<PBaseAssistantmaterialProductpurpose> getProductpurposesByCode(
			String productpurposeCode) throws Throwable {
		return productPurposeDAOProxy.getProductpurposesByCode(productpurposeCode);
	}
	@Override
	public List<PBaseAssistantmaterialProductpurpose> getProductpurposesByCodeAndName(
			String productpurposeCode, String productpurposeName)
			throws Throwable {
		return productPurposeDAOProxy.getProductpurposesByNameAndCode(productpurposeName, productpurposeCode);
	}
	@Override
	public List<PBaseAssistantmaterialProductpurpose> getProductpurposesByName(
			String productpurposeName) throws Throwable {
		return productPurposeDAOProxy.getProductpurposesByName(productpurposeName);
	}
	/**
	 * 动态查询辅助资料领料用途
	 *//*
	@Override
	public List<PBaseAssistantmaterialProductpurpose> getProductpurposes(PBaseAssistantmaterialProductpurpose productpurpose)throws Throwable {
		// TODO Auto-generated method stub
		
		//领料用途list
		List<PBaseAssistantmaterialProductpurpose>  productpurposeList = null ;
		
		//productpurpose为null时
		if(productpurpose==null){
			productpurposeList = productPurposeDAOProxy.getAllproductpurposes();
		}
		else{//productpurpose不为null
			//领料用途name
			String name = productpurpose.getProductPurposeName() ;
			//领料用途code
			String code = productpurpose.getProductPurposeCode() ;
			if(!name.equals("")&&!code.equals("")){//根据name和code查询
				productpurposeList = productPurposeDAOProxy.getProductpurposesByNameAndCode(name, code) ;
			}
			else if(!name.equals("")){//根据name查询
				productpurposeList = productPurposeDAOProxy.getProductpurposesByName(name) ;
			}
			else if(!code.equals("")){//根据code查询
				productpurposeList = productPurposeDAOProxy.getProductpurposesByCode(code) ;
			}
			else 
				productpurposeList = productPurposeDAOProxy.getAllproductpurposes() ;
		}
				
		return productpurposeList;
	}*/
	/**
	 * 根据id查询辅助资料领料用途
	 */
	@Override
	public PBaseAssistantmaterialProductpurpose getProductpurposeById(
			Integer productpurposeId) throws Throwable{
		// TODO Auto-generated method stub
		//辅助资料领料用途model
		PBaseAssistantmaterialProductpurpose productpurpose = null;
		
		productpurpose = productPurposeDAOProxy.getProductpurposeById(productpurposeId);
		
		return productpurpose;
	}
	/**
	 * 更新辅助资料领料用途
	 */
	@Override
	public void updateProductpurpose(
			PBaseAssistantmaterialProductpurpose productpurpose) throws Throwable{
		// TODO Auto-generated method stub		
		
		productPurposeDAOProxy.updateProductpurpose(productpurpose) ;
		
	}
	/**
	 * setters and getters for instance variables
	 * @return
	 */
	public PBaseAssistantmaterialProductpurposeDAO getProductPurposeDAOProxy() {
		return productPurposeDAOProxy;
	}
	public void setProductPurposeDAOProxy(
			PBaseAssistantmaterialProductpurposeDAO productPurposeDAOProxy) {
		this.productPurposeDAOProxy = productPurposeDAOProxy;
	}
	
	
}
